/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './weixinyonghujihua';
import * as API from './types';

/** 根据id删除计划 GET /tourism/client/c/plan/deleteplan */
export function deletePlanUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.deletePlanUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.deletePlanUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['deletePlanUsingGet', options],
  });
}

/** 分页获取计划 GET /tourism/client/c/plan/getplan */
export function getPlanUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.getPlanUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.getPlanUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['getPlanUsingGet', options],
  });
}

/** 根据id获取计划 GET /tourism/client/c/plan/getplanbyid */
export function getPlanByIdUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.getPlanByIdUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.getPlanByIdUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['getPlanByIdUsingGet', options],
  });
}

/** 保存计划 POST /tourism/client/c/plan/saveplan */
export function useGetPlanUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.getPlanUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 根据id修改计划 POST /tourism/client/c/plan/updateplan */
export function useUpdatePlanUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.updatePlanUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}
